cmake_minimum_required(VERSION 3.18)
PROJECT(VideoOcr)
#添加-PIC编译参数
SET(POSITION_INDEPENDENT_CODE True)
#添加-rpath参数
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
find_package(OpenCV REQUIRED)

INCLUDE_DIRECTORIES(include)


AUX_SOURCE_DIRECTORY(include INC_FILES)
AUX_SOURCE_DIRECTORY(src SRC_FILES)

SET(POSITION_INDEPENDENT_CODE True)

SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
file(GLOB VideoSubTitle_src
     "include/*.h"
     "src/*.cpp"
)
set(main test.cpp)
ADD_LIBRARY(VideoOcr SHARED ${VideoSubTitle_src})
SET_TARGET_PROPERTIES(VideoOcr PROPERTIES OUTPUT_NAME "VideoOcr")
SET_TARGET_PROPERTIES(VideoOcr PROPERTIES CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES(VideoOcr PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
#添加头文件路径
target_include_directories(VideoOcr PUBLIC
	"include"
	${OpenCV_INCLUDE_DIRS}
)
#限定CXX标准CXX17
target_compile_features(VideoOcr PUBLIC cxx_std_17)

TARGET_LINK_LIBRARIES(VideoOcr ${OpenCV_LIBS})
target_link_options(VideoOcr PRIVATE "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib")

ADD_EXECUTABLE(VideoOcr_bin ${main} ${VideoSubTitle_src})
SET_TARGET_PROPERTIES(VideoOcr_bin PROPERTIES OUTPUT_NAME "VideoOcr")
SET_TARGET_PROPERTIES(VideoOcr_bin PROPERTIES CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES(VideoOcr_bin PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
#添加头文件路径
target_include_directories(VideoOcr_bin PUBLIC
	"include"
	${OpenCV_INCLUDE_DIRS}
)
#限定CXX标准CXX17
target_compile_features(VideoOcr_bin PUBLIC cxx_std_17)
TARGET_LINK_LIBRARIES(VideoOcr_bin ${OpenCV_LIBS})
target_link_options(VideoOcr_bin PRIVATE "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib")


